<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let p1 = new Promise((resolve,reject) =>{
            reject(new Error("错误"));
        })

        // then方法会有一个返回值 返回的也是promise对象
        p1.then(data =>{
            console.log("正确");
        }).catch(error =>{   //会捕获上面的错误
            console.log(error);
        })



        let p2= new Promise((resolve,reject) =>{
           throw new Error("主动抛出的错误");
           resolve("成功");
        })

        p2.then(data =>{
            console.log("正确");
        }).catch(error =>{   //会捕获上面的错误
            console.log(error);
        })
    </script>
</body>
</html>